<?php
require_once '../conf/DbConnector.php';

$book = $_POST['book'];

$db=mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME)
		or die('<p><font color=red>Fehler bei der Datenbankverbindung: '.
		mysqli_connect_errno().': '.mysqli_connect_error().'</p>');	

$sql="SELECT Book.Book_Name, Book.Book_ID,Book.Book_Vol, Book.Book_Cover, Series.Ser_ID,Series.Ser_Name, Author.Auth_Name
FROM Author, Book, Series, Book_has_Lang
WHERE Book.Book_ID = " . $book . " 
AND Book.Series_Ser_ID = Series.Ser_ID
AND Book.Author_Auth_ID = Author.Auth_ID
GROUP BY Book.Book_ID";

$result = mysqli_query($db, $sql);

$zeile=mysqli_fetch_array($result);


                  
$result = mysqli_query($db, $sql);
?>

<div class="book">
        
        <div class="cover">
    <svg xmlns="http://www.w3.org/2000/svg" height="100%" 
         preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 200 400" 
         width="100%" xmlns:xlink="http://www.w3.org/1999/xlink">
        <?php if (file_exists("../images/books/$zeile[Ser_ID]/$zeile[Book_ID]/cover.jpg")){  ?>
      <image height="400" width="200" xlink:href="../images/books/<?php echo $zeile['Ser_ID']; ?>/<?php echo $zeile['Book_ID']; ?>/cover.jpg"></image>
        <?php } else { ?>
      <image height="400" width="200" xlink:href="../images/err/404.jpg"></image>
        <?php } ?>
    </svg>
  </div>
        
<div class="BTEXT">
<?php if (isset($zeile['Ser_Name'])) { ?>
        
        <p><b>Series:</b> <?php echo $zeile['Ser_Name']; ?></p>
        
<?php } ?>
        
<?php if (isset($zeile['Book_Name'])) { ?>
        
        <p><b>Titel:</b> <?php echo $zeile['Book_Name']; ?></p>
        
<?php } ?>
        
<?php if (isset($zeile['Vook_Vol'])) { ?>
        
        <p><b>Volume:</b> <?php echo $zeile['Book_Vol']; ?></p>
        
<?php } ?>
        
<?php if (isset($zeile['Auth_Name'])) { ?>
        
        <p><b>Author:</b> <?php echo $zeile['Auth_Name']; ?></p>
        
<?php } ?>
</div>
        
        
<?php 

$sql2="SELECT DL_Link, Extentions.Ext_Name, Creator.Creator_Name 
FROM LNDL, Extentions, Creator
WHERE LNDL.Book_Book_ID = " . $book . "
AND Extentions.Ext_ID = LNDL.Extentions_Ext_ID
AND Creator.Creator_ID = LNDL.Creator_Creator_ID
ORDER BY LNDL.Extentions_Ext_ID";

$result2 = mysqli_query($db, $sql2);
?>
<div class="BTEXT"> 
<?php
while ($zeile2=mysqli_fetch_array($result2)){
?>
   
        <p><a href="<?php echo $zeile2['DL_Link']; ?>"><?php echo $zeile2['Ext_Name']; ?></a> BY <?php echo $zeile2['Creator_Name']; ?></p>
        
<?php

}

mysqli_close($db); 
?>
        
</div>    
</div>